package com.lanou3g.hw0412;

/**
 * Created by dllo on 18/4/10.
 */
public class OperatorFactory {
    // 根据操作符(+ - * /)
    //来生成 指定的计算类
    // 工厂模式
    public static Operator getOperator(String op) {
        Operator operator = null;
        switch (op) {
            case "+":
                operator = new OpAdd();
                break;
            case "-":
                operator = new OPSub();
                break;
            case"*":
                operator =new OpMultiply();
                break;
            case "/":
                operator=new Opdevide();
                break;
            case "^":
                operator=new OPPower();
        }
        return operator;
    }
}
